package com.tony.springbootmybatis.controller;

import com.tony.springbootmybatis.entity.Student;
import com.tony.springbootmybatis.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * create by xuxia on 2024/1/31 17:38
 */
@RestController
public class DruidDemoController {

    @Autowired
    private StudentService studentService;

    @RequestMapping("/queryStudent")
    public Student queryStudent(String sno) {
        return studentService.queryStudentById(sno);
    }

    @RequestMapping("/addStudent")
    public void addStudent() {
        Student student = new Student("004", "李源", "man");
        studentService.add(student);
    }

    @RequestMapping("/aa")
    public String aa(String sno){
        return "qweqwewqe";
    }

    @RequestMapping("/updateStudent")
    public void updateStudent(String sno) {
        Student student = studentService.queryStudentById(sno);
        student.setSname("李东");
        studentService.update(student);
    }
}
